package com.kedeng.yangmuyi.validator;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.kedeng.yangmuyi.dto.LoginUserDTO;

/**
 * validate login form information.
 * 
 * @author: rqian
 * @version: 1.0, Nov 20, 2013
 */
@Component
public class LoginFormValidator implements Validator {

    @Override
    public boolean supports(Class<?> clazz) {
        return LoginUserDTO.class.isAssignableFrom(clazz);
    }



    @Override
    public void validate(Object target, Errors errors) {
        ValidationUtils
                .rejectIfEmptyOrWhitespace(errors, "email", "required.login.username", "login name is required.");
    }

}
